package com.example.service;

import com.example.entity.Admissions;
import com.example.mapper.AdmissionsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdmissionsService {

    @Resource
    private AdmissionsMapper AdmissionsMapper;

    /**
     * 新增
     */
    public void add(Admissions Admissions) {
        AdmissionsMapper.insert(Admissions);
    }

    /**
     * 删除
     */
    public void deleteById(Integer id) {
        AdmissionsMapper.deleteById(id);
    }

    /**
     * 批量删除
     */
    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids) {
            AdmissionsMapper.deleteById(id);
        }
    }

    /**
     * 修改
     */
    public void updateById(Admissions Admissions) {
        AdmissionsMapper.updateById(Admissions);
    }

    /**
     * 根据ID查询
     */
    public Admissions selectById(Integer id) {
        return AdmissionsMapper.selectById(id);
    }

    /**
     * 查询所有
     */
    public List<Admissions> selectAll(Admissions Admissions) {
        return AdmissionsMapper.selectAll(Admissions);
    }

    /**
     * 分页查询
     */
    public PageInfo<Admissions> selectPage(Admissions Admissions, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Admissions> list = AdmissionsMapper.selectAll(Admissions);
        return PageInfo.of(list);
    }


}
